<%-- 
    Document   : userSearchResult
    Created on : 06.11.2011, 0:01:35
    Author     : Дима
--%>

<%@page import="java.util.Iterator"%>
<%@page import="ru.ssau.utils.XMLHelper"%>
<%@page import="ru.ssau.server.Constants"%>
<%@page import="ru.ssau.entities.User"%>
<%@page import="java.util.Collection"%>
<%@page errorPage="error.jsp"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>   <%
        String usersXML = (String) session.getAttribute(Constants.FOUND_USERS);
        Collection<User> users = XMLHelper.loadUsers(XMLHelper.parseString(usersXML).getChild(Constants.VALUES_XML_TAG)); %>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h3>User search result: </h3>
        <ol>   <%
            Iterator<User> iterator = users.iterator();
            while(iterator.hasNext()) {
                User user = iterator.next();
                %>
                <li><%=user.toString()%></li>&nbsp&nbsp   <%
                    String editLink = String.format("request?%s=%s&%s=%d",
                    Constants.ACTION, Constants.EDIT_USER, Constants.ID, user.getId()); %>
                <a href="<%=editLink%>"><b>Edit</b></a>&nbsp&nbsp   <%
                    String deleteLink = String.format("request?%s=%s&%s=%d",
                    Constants.ACTION, Constants.DELETE_USER, Constants.ID, user.getId()); %>
                <a href="<%=deleteLink%>"><b>Delete</b></a>   <%
            } %>
        </ol>
        <a href="<%=String.format("request?%s=%s", Constants.ACTION, Constants.GET_MODEL_STATE)%>">
            go to main page
        </a>
    </body>
</html>
